package binarysearch.test275;

/**
 * H 指数 2
 * @author code_yc
 * @version 1.0
 * @date 2020/7/11 12:49
 */
public class Solution1 {

    // 二分
    public int hIndex(int[] citations) {
        int n = citations.length;
        int l = 0, r = n;
        while (l < r) {
            int mid = (l + r + 1) >> 1;
            if (citations[n - mid] >= mid) {
                l = mid;
            } else {
                r = mid - 1;
            }
        }
        return l;
    }
}
